package excel

import (
	"log"

	"github.com/xuri/excelize/v2"
)

// official toturail address:
// https://xuri.me/excelize/zh-hans/base/installation.html#install

// github link:
// github.com/xuri/excelize/v2

// 读取excel转换为数组
// filePath是文件地址 ../demo.xlsx 相对地址与绝对地址
// sheet是工作表默认Sheet1
func ReadConvArray(filePath string, sheet string) ([][]string, error) {
	// 打开Excel文件
	f, err := excelize.OpenFile("../demo.xlsx")
	if err != nil {
		log.Println("打开文件失败err:", err)
		return nil, nil
	}
	if sheet == "" {
		sheet = "Sheet1"
	}
	rows, err := f.GetRows(sheet)
	return rows, err
}
